package org.micode.demo.biz.vo;

import org.micode.demo.db.cache.user.SysUserCache;
import org.micode.demo.db.domain.dto.SysUserDTO;
import lombok.Data;

@Data
public class SysUserVO {

    /**
     * 登录用户ID
     */
    private Long userId;

    /**
     * 用户类型
     */
    private Integer userType;

    /**
     * 登录用户名
     */
    private String loginName;

    /**
     * 登录用户密码
     */
    private String loginPassword;

    private String uuid;
    private String imageCode;

    /**
     * 登录凭证
     */
    private String token;

    /**
     * 登录的应用
     */
    private String loginApp;

    /**
     * 登录的IP
     */
    private String loginIp;

    public SysUserCache copyToCache() {
        SysUserCache ret = new SysUserCache();
        ret.setUserId(userId);
        ret.setUserType(userType);
        ret.setLoginName(loginName);
        ret.setLoginApp(loginApp);
        ret.setLoginIp(loginIp);
        return ret;
    }

    public static SysUserVO fromDTO(SysUserDTO dto) {
        SysUserVO ret = new SysUserVO();
        ret.setUserId(dto.getUserId());
        ret.setUserType(dto.getUserType());
        ret.setLoginName(dto.getLoginName());
        return ret;
    }

}
